package domfarr.tapestry.pages;

import java.text.Format;
import java.util.List;

import org.apache.tapestry5.annotations.ApplicationState;
import org.apache.tapestry5.ioc.annotations.Inject;

import domfarr.tapestry.data.DataSource;
import domfarr.tapestry.model.Celebrity;
import domfarr.tapestry.model.User;
import domfarr.tapestry.util.Formats;

public class ShowAll {
	private Celebrity celebrity;

	@Inject
	private DataSource dataSource;

	public DataSource getDataSource() {
		return dataSource;
	}

	public void setDataSource(DataSource dataSource) {
		this.dataSource = dataSource;
	}

	@SuppressWarnings("unused")
	@ApplicationState
	private User user;

	private boolean userExists;

	public List<Celebrity> getAllCelebrities() {
		return dataSource.getAllCelebrities();
	}

	public Celebrity getCelebrity() {
		return celebrity;
	}

	public Format getDateFormat() {
		return Formats.getDateFormat();
	}

	String onActivate() {
		if (!userExists)
			return "Start";
		return null;
	}

	public void setCelebrity(Celebrity celebrity) {
		this.celebrity = celebrity;
	}

}
